package com.jinken.controller;

import com.jinken.entity.User;
import com.jinken.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController {


    @Autowired
    private UserService userService;

    @GetMapping("/user/list")
    public List<User> userList() throws InterruptedException {
        Thread.sleep(100);
        return userService.findAll();
    }
    //每次调用睡眠1.5秒，模拟超时的报警
    @GetMapping("/timeout")
    public String timeout() {
        try {
            Thread.sleep(1500);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "timeout";
    }
}
